<?php
/**
 * A basic stack; a first on last off data structure
 *
 * @package junction.utils
 * @author Alexander Schearer <aas11@duke.edu>
 */
class Utils_Stack {
	
	/**
	 * Data array
	 *
	 * @var array
	 */
	private $_data;
	
	public function __construct() {
		$this->_data = array();
	}
	
	/**
	 * Push a new element on to the top of the stack
	 *
	 * @param unknown_type $value
	 */
	public function push($value) {
		$this->_data[] = $value;
	}
	
	/**
	 * Pop the top element off the stack
	 *
	 * @return unknown_type
	 */
	public function pop() {
		return array_pop($this->_data);
	}
	
	/**
	 * Retrieve the top element but leave it on the stack
	 *
	 * @return unknown_type
	 */
	public function peek() {
		return end($this->_data);
	}
	
	/**
	 * Return the size of the stack
	 *
	 * @return int
	 */
	public function size() {
		return count($this->_data);
	}
}
?>